<?php

namespace App\Http\Middleware\Api;


use Closure;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Support\Facades\Auth;
use App\Api\Helpers\ApiResponse;
class UserStatus
{
    use ApiResponse;
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user = Auth::guard('api')->user();

        if($user && $user->status==1){//拉黑用户拦截
            //dd($user);

            return $this->failed($user->reason);

        }

        return $next($request);
    }

}
